<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>已签到服务</title>
		<!-- css代码 start -->
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../css/global.css" rel="stylesheet" />
		<link href="../../../css/style.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../../css/mui.picker.css">
		<link rel="stylesheet" href="../../../css/mui.poppicker.css">
		<link rel="stylesheet" href="../../../css/task.css">
		<style>
			.d_int_tp{
				border: 0 !important;
				margin-top: 6px !important;
			}
			.details_con .btm .selectBtn {
			    line-height: 28px;
			    color: #ffffff;
			    background: #ea1e1a;
			}
			
			.item_box .item .text{
				margin: 5px auto;
			}
			.item_box .item .text span.cen{
				margin-left:0;
			}
			.item_box .item .text span{
				width: auto;
			}
			.select-tzstate{
				width: 100%;
				border: 0;
				color: #a9a9a9;
				font-size: 16px;
				text-align: left;
				padding: 15px;
			}
			.mui-bar-nav{
				box-shadow: 0 1px 6px #ea1e1a;
			}
		</style>
		<!-- css代码 end -->
	</head>

	<body>
		<!-- html代码 start -->
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">已签到服务</h1>
		</header>
		<div class="mui-content">
			
			<div class="details_con select_con" id="search">
				<div class="clum">
					<input type="text" class="d_int_tp" id="customerName" placeholder="输入客户名称" />
				</div>
				<div class="clum">
					<!-- <input type="text" class="d_int_tp" id="serviceType" placeholder="输入服务类型" /> -->
					<span class="txt" style="width: 100%;">
						<input type="hidden" id="serviceTypeValue" />
						<button id='serviceType' class="mui-btn mui-btn-block mui-btn-select select-tzstate" type='button'>请选择服务子类型</button>
					</span>
				</div>
				<div class="clum">
					<input type="text" class="d_int_tp" id="instrumentSerialNumber" placeholder="输入仪器序列号" />
				</div>
				<div class="btm autoHeight">
					<p class="selectBtn" id="searchBtn" onclick="initData()">查 询</p>
				</div>
			</div>
			
			<div class="details_con" style="margin: 30px 0 0 0;">
				<div class="item_box" id="itemBox">
				</div>
			</div>
			<div style="height: 50px;"></div>
		</div>
		<!-- html代码 end -->
		
		<!-- js代码 start -->
		
		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<!-- 基础js end -->
		<script src="../../../js/mui.picker.js"></script>
		<script src="../../../js/mui.poppicker.js"></script>
		<script type="text/javascript" charset="utf-8">
			
			function initData(){
				
				app.showWaiting('加载中...')
				var customerName = h("#customerName").val();
				var serviceType = h("#serviceType").html();
				if(serviceType=='请选择服务子类型'){
					serviceType = ""
				}
				var instrumentSerialNumber = h("#instrumentSerialNumber").val();
				
				ajaxGet(BASE_URL + "cc/notice/getServiceNoticeList", {
					"EnginnerId": app.getUser().enginnerId,
					"state": '2',
					"customerName": customerName,
					"serviceType": serviceType,
					"instrumentSerialNumber": instrumentSerialNumber
				}, function(data) {
					app.closeWaiting()
					console.log(JSON.stringify(data))
					if (data.code === 200) {
						var str = '';
						if (data.data && data.data.length > 0) {
							 for(var c = 0;c<data.data.length;c++){
								 
								 /* var xianshi = '';
								 var enginnerType = data.data[c].enginnerType==undefined?"":data.data[c].enginnerType;
								 var isVip = data.data[c].isVip==undefined?"":data.data[c].isVip;
								 var userIsdpel = data.data[c].userIsdpel==undefined?"":data.data[c].userIsdpel;
								 if(userIsdpel=='1'){
								 	xianshi = ''
								 }
								 if(isVip!=''){
								 	xianshi += isVip
								 }else{
								 	if(enginnerType!=''){
								 		xianshi += enginnerType
								 	}
								 } */
								 
								 var enginnerType = data.data[c].enginnerType ? data.data[c].enginnerType : "";
								 var customerName = data.data[c].customerName ? data.data[c].customerName : "";
								 var createTime = data.data[c].createTime ? data.data[c].createTime : "";
								 var serviceType = data.data[c].subServiceType ? data.data[c].subServiceType : "";
								 str += '<div class="item" onclick="viewSignIn(\''+data.data[c].id+'\',\''+data.data[c].serviceNo+'\',\''+data.data[c].planId+'\',\''+data.data[c].subServiceType+'\',\''+data.data[c].isCheck+'\',\''+data.data[c].snflag+'\')">';
								 str += '<div class="bar">';
								 str += '<span class="number"><img src="../../../images/icon_204.png" />'+data.data[c].serviceNo+'</span>';		
		
									 str += '<span class="vip">'+enginnerType+'</span>';
						
								 str += '</div>';
								 str += '<div class="text autoHeight">';
								 str += '<span class="cen" style="color: #333">'+customerName+'</span>';
								 str += '</div>';
								 str += '<div class="type">';
								 str += '<p><img src="../../../images/icon_202.png"/><span class="lpl">提交时间：</span><span>'+createTime+'</span></p>';
								 str += '<p><img src="../../../images/icon_203.png"/><span class="lpl">服务子类型：</span><span>'+serviceType+'</span></p>';
								 if(serviceType == "安装"){
									 if(data.data[c].isCheck == "2"){ //已核对
										str += '<p><img src="../../../images/icon_368.png"/><span>序列号已核对</span></p>';
									 } else {
									 	str += '<p><img src="../../../images/icon_368.png"/><span>序列号未核对</span></p>';
									 }
								 }
								 str += '</div>';
								 str += '</div>';
							 }
							 h('#itemBox').html(str);
						}else{
							var html = '<div class="nodata">—— 暂无数据 ——</div>';
							h("#itemBox").html(html);
						}
					} else {
						var html = '<div class="nodata">—— 暂无数据 ——</div>';
						h("#itemBox").html(html);
						app.toast(data.msg)
					}
				}, function(errorMsg) {
					app.closeWaiting();
					var html = '<div class="nodata">—— 暂无数据 ——</div>';
					h("#itemBox").html(html);
					app.toast("数据获取失败，请检查网络连接");
				});
			}
			
			(function($, doc) {
				$.init();
		
					$.plusReady(function() {
						var self = plus.webview.currentWebview();
						initData()
						
						// 服务子类型下拉
						h('#serviceType').tap(function() {
							var userPicker = new $.PopPicker();
							ajaxGetJson(BASE_URL + 'cc/dict/selectCCDict', {
								tableName: 'snsubtype',
								engineerId: app.getUser().enginnerId
							}, function(data) {
								console.log(JSON.stringify(data))
								if (!data) {
									app.toast("无下拉内容")
									return
								}
								// 数组指定位置插入数据
								data.splice(0, 0, {"text":"请选择服务子类型","value":""});
								userPicker.setData(data);
								userPicker.show(function(items) {
									h('#serviceType').html(items[0].text)
									h('#serviceTypeValue').val(items[0].value)
									userPicker.dispose()
								});
							});
						});
						
						h('.mui-action-back').tap(function () {
							var noticeMenu=plus.webview.getWebviewById('view/service/notice/noticeMenu.html');
							if(noticeMenu){
								noticeMenu.evalJS('getNoticeCount()')
							}
						})
					});
				}(mui, document));
				
				function viewSignIn(ServiceNoticeId,serviceNo,planId,subServiceType,isCheck,snflag){
					//判断是否写日志
					ajaxPost(BASE_URL + "cc/ServiceLog/selectServiceLogList", {
						"stPlanId": planId
					}, function(data) {
						console.log(data)
						if (data.code === 200) {
							//判断服务类型是安装还是非安装
							if(subServiceType == "安装"){
								//如果是安装单，判断是否已核对
								if(isCheck == "2"){  //已核对
									//判断有没有日志
									if(data.data && data.data.length > 0){
										app.jumpTo("/view/service/notice/signOutAddReport.html", "view/service/notice/signOutAddReport.html",{
											ServiceNoticeId: ServiceNoticeId,
											serviceNo: serviceNo,
											planId:planId
										});
									}else{
										app.jumpTo('/view/service/notice/signOut.html','view/service/notice/signOut.html',{
											ServiceNoticeId:ServiceNoticeId,
											serviceNo:serviceNo,
											planId:planId,
										});
									}
								}else{  //跳转到核对页面
									var logFlag = 1
									if(data.data == "" || data.data.length == 0 || data.data == null || data.data == undefined){  //没日志
										logFlag = 0
									}
									app.jumpTo('/view/service/checkInstrument/checkInstrument.html','view/service/checkInstrument/checkInstrument.html',{
										serviceNo:serviceNo,
										ServiceNoticeId:ServiceNoticeId,
										planId:planId,
										logFlag:logFlag
									});
								}
							}else{   //非安装单
								if(data.data && data.data.length > 0){				
									app.jumpTo("/view/service/notice/signOutAddReport.html", "view/service/notice/signOutAddReport.html",{
										ServiceNoticeId: ServiceNoticeId,
										serviceNo: serviceNo,
										planId:planId
									});
								}else{
									app.jumpTo('/view/service/notice/signOut.html','view/service/notice/signOut.html',{
										ServiceNoticeId:ServiceNoticeId,
										serviceNo:serviceNo,
										planId:planId,
									});
								}
							}
						} else {
							app.toast('查询日志失败')
						}
					}, function(errorMsg) {
						app.toast('查询日志失败')
					});
					
				}
		</script>
		<!-- js代码 end -->
	</body>

</html> 
